﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ingineria_prog
{
    class Program
    {
        static void Main(string[] args)
        {
            string nume;
            int varsta;
            int tip;
            List<Client> listaclienti;
            listaclienti = new List<Client>();
            Client c1=new Client();

            int mod;
            while(true)
            {
                string dotari, motorizare, dimensiuni, transmisie, culoare;
              
                Console.WriteLine("1 = introducere client/masina");
    
                Console.WriteLine("2= afisare lista clienti");

                Console.WriteLine("3= Sterge masina unui anumit user");
               
                Console.WriteLine("4= exit");
                
            mod = Convert.ToInt32(Console.ReadLine());

            if (mod == 1)
            {
                Console.Write("Introduceti numele Clientului: ");
                nume = Console.ReadLine();
                Console.Write("Introduceti varsta Clientului: ");
                varsta = Convert.ToInt32(Console.ReadLine());
                Console.Write("Introduceti tipul de masina: 1 = Sedan 2 = Coupe 3 = Mini");
                tip = Convert.ToInt32(Console.ReadLine());
                Car car1;
                Console.WriteLine("Introduceti :");
                Console.Write("Dotarile:");
                dotari = Console.ReadLine();
                Console.Write("Motorizare:");
                motorizare = Console.ReadLine();
                Console.Write("Dimensiuni:");
                dimensiuni = Console.ReadLine();
                Console.Write("Transmisie:");
                transmisie = Console.ReadLine();
                Console.Write("Culoare:");
                culoare = Console.ReadLine();





               int gasit = 0;
                if (tip == 1)
                {

                    //  Client c1 = new Client();
                    AbstractCarFactory sedFactory = SedanFactory.getSedanFactory();
                    car1 = ((SedanFactory)sedFactory).getSedan();
                    car1.setTip("sedan");
                    car1.setDotari(dotari);
                    car1.setMotorizare(motorizare);
                    car1.setDimensiuni(dimensiuni);
                    car1.setTransmisie(transmisie);
                    car1.setCuloare(culoare);

                    foreach (Client c in listaclienti)
                    {
                        if (c.getNume == nume)
                        {
                            c.AddCar(car1);
                            gasit = 1;
                        }
                    }

                    if (gasit == 0)
                    {
                        c1 = new Client();
                        c1.addNume(nume);
                        c1.addVarsta(varsta);
                        c1.AddCar(car1);
                        listaclienti.Add(c1);
                    }
                 


                   

                }
                else if (tip == 2)
                {
                    AbstractCarFactory coupeFactory = CoupeFactory.getCoupeFactory();
                    car1 = ((CoupeFactory)coupeFactory).getCoupe();
                    car1.setTip("Coupe");
                    car1.setDotari(dotari);
                    car1.setMotorizare(motorizare);
                    car1.setDimensiuni(dimensiuni);
                    car1.setTransmisie(transmisie);
                    car1.setCuloare(culoare);


                    foreach (Client c in listaclienti)
                    {
                        if (c.getNume == nume)
                        {
                            c.AddCar(car1);
                            gasit = 1;
                        }
                    }
                    if (gasit == 0)
                    {
                        c1 = new Client();
                        c1.addNume(nume);
                        c1.addVarsta(varsta);
                        c1.AddCar(car1);
                        listaclienti.Add(c1);
                    }
                }
                else if (tip == 3)
                {
                    AbstractCarFactory minFactory = MiniFactory.getMiniFactory();
                    car1 = ((MiniFactory)minFactory).getMini();
                    car1.setTip("Mini");
                    car1.setDotari(dotari);
                    car1.setMotorizare(motorizare);
                    car1.setDimensiuni(dimensiuni);
                    car1.setTransmisie(transmisie);
                    car1.setCuloare(culoare);

                    foreach (Client c in listaclienti)
                    {
                        if (c.getNume == nume)
                        {
                            c.AddCar(car1);
                            gasit = 1;
                        }
                    }
                    if (gasit == 0)
                    {
                        c1 = new Client();
                        c1.addNume(nume);
                        c1.addVarsta(varsta);
                        c1.AddCar(car1);
                        listaclienti.Add(c1);
                    }

                }
                else
                {
                    Console.Write("Valoarea Introdusa nu este corecta");

                }
            }
            else if (mod == 2)
            {
                foreach (Client client in listaclienti)
                {
                    client.afiseaza();
                }
            }
            else if (mod == 3)
            {
                string name; string tip1;
                Console.Write("Introduceti numele Clientului: ");
                name = Console.ReadLine();
                Console.Write("Introduceti tipul de masina pe care doriti sa-l stergeti: sedan/coupe/mini");
                tip1 =(Console.ReadLine());

                foreach (Client c in listaclienti)
                {
                    if (c.getNume == name)
                    {
                        

                        c.DeleteCar(tip1);

              
                    }
                }
                
            }
            else if (mod == 4)
            {
                Environment.Exit(0);
            }



            }




        }
    }
}


